//
//  People.m
//  People
//
//  Created by 曾泽昱 on 2024/7/11.
//

#import "People.h"
#import "ViewController.h"

@interface ViewController()

@property (nonatomic,strong) People* p;

@end

@implementation ViewController

-(void)viewDidLoad{
    [super viewDidLoad];
    People* person = [[People alloc] init];
    person.name = @"花无缺";
    self.p = person;
    [person addObserver:self forKeyPath:@"name" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:nil];
    person.name = @"小鱼儿";

}

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
    NSLog(@"%@",change);
    
}

-(void)dealloc{
    [self.p removeObserver:self forKeyPath:@"name"];
}

@end

@implementation People









@end

